package com.itheima.stock.controller;

import com.itheima.stock.api.StockControllerAPI;
import com.itheima.stock.domain.StockUpdownDomain;
import com.itheima.stock.entity.StockBlockRtInfo;
import com.itheima.stock.entity.StockBusiness;
import com.itheima.stock.response.ResponseResult;
import com.itheima.stock.service.StockService;
import com.itheima.stock.vo.InnerMarketVO;
import com.itheima.stock.vo.PageResult;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author zby
 * @created 2024-06-23 16:33
 * @description
 */
@RestController
public class StockController implements StockControllerAPI {

    private final StockService stockService;

    public StockController(StockService stockService) {
        this.stockService = stockService;
    }

    @Override
    public ResponseResult<Map> upDownCount() {
        return stockService.upDownCount();
    }

    @Override
    public ResponseResult<PageResult<StockUpdownDomain>> stockPage(Integer page, Integer pageSize) {
        return stockService.stockPage(page, pageSize);
    }

    @Override
    public ResponseResult<List<StockUpdownDomain>> stockIncreaseLimit() {
        return ResponseResult.ok(stockService.stockIncreaseLimit());
    }

    /**
     *需求说明: 沪深两市板块分时行情数据查询，以交易时间和交易总金额降序查询，取前10条数据
     *
     */
    @Override
    public ResponseResult<List<StockBlockRtInfo>> sectorAll() {
        return ResponseResult.ok(stockService.sectorAllLimit());
    }

    @Override
    public ResponseResult<List<InnerMarketVO>> innerIndexAll() {
        return ResponseResult.ok(stockService.innerIndexAll());
    }

    @Override
    public ResponseResult<List<StockBusiness>> getStockBusiness() {
        List<StockBusiness> stockBusiness = stockService.getStockBusiness();
        return ResponseResult.ok(stockBusiness);
    }
}
